/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vn.ikame.android.utils;

import android.app.Activity;
import android.content.SharedPreferences;

/**
 * 
 * @author KienVN
 */
public class CStore {
	SharedPreferences prefs;
	private SharedPreferences.Editor editor;
	private boolean purchase;
	private boolean showAbout;
	
	private String storyName, chapName;
	private int storyID, chapID, chapPos;

	public CStore(Activity activity) {
		prefs = activity.getPreferences(android.content.Context.MODE_PRIVATE);
		this.editor = prefs.edit();
		LoadData();
	}

	private void LoadData() {
		purchase = prefs.getBoolean("purchaseFMA", false);
		showAbout = prefs.getBoolean("showAbout", false);
		storyName = prefs.getString("storyName", "");
		chapName = prefs.getString("chapName", "");
		storyID = prefs.getInt("storyID", 0);
		chapID = prefs.getInt("chapID", 0);
		chapPos = prefs.getInt("chapPos", 0);
	}

	private void Save() {
		editor.putBoolean("purchaseFMA", purchase);
		editor.putBoolean("showAbout", showAbout);
		editor.putString("chapName", chapName);
		editor.putString("storyName", storyName);
		editor.putInt("chapID", chapID);
		editor.putInt("storyID", storyID);
		editor.putInt("chapPos", chapPos);
		editor.commit();
	}

	
	
	public int getChapPos() {
		return chapPos;
	}

	public void setChapPos(int chapPos) {
		this.chapPos = chapPos;
		Save();
	}

	public int getStoryID() {
		return storyID;
	}

	public void setStoryID(int storyID) {
		this.storyID = storyID;
		Save();
	}

	public int getChapID() {
		return chapID;
	}

	public void setChapID(int chapID) {
		this.chapID = chapID;
		Save();
	}

	public String getStoryName() {
		return storyName;
	}

	public void setStoryName(String storyName) {
		this.storyName = storyName;
		Save();
	}

	public String getChapName() {
		return chapName;
	}

	public void setChapName(String chapName) {
		this.chapName = chapName;
		Save();
	}

	public void setPurchase(boolean purchase) {
		this.purchase = purchase;
		Save();
	}

	public boolean isPurchase() {
		return this.purchase;
	}

	public boolean isShowAbout() {
		return showAbout;
	}

	public void setShowAbout(boolean showAbout) {
		this.showAbout = showAbout;
		Save();
	}

	
}
